<div class="row">
    <div class="col-lg-9">
        <div class="card">
            <div class="card-body">
                <div class="table-responsive">
                    <form method="post" id="form-list" action="index.php?r=plugins/service">
                        <input type="hidden" name="action_type" value="">
                        <input type="hidden" name="plug_service_id">
                        <table class="table">
                            <thead>
                            <tr>
                                <th>图标</th>
                                <th>标题</th>
                                <th>描述</th>
                                <th>排序</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php
                            foreach ($services as $service) {
                                ?>
                                <tr>
                                    <td><?php echo $service['icon_cls']; ?></td>
                                    <td><?php echo $service['title'] ?></td>
                                    <td><?php echo $service['description']; ?></td>
                                    <td><?php echo $service['seq']; ?></td>
                                    <td>
                                        <button type="button" onclick="edit(<?php echo $service['plug_service_id']; ?>)" class="btn btn-primary btn-sm m-l-5">编辑</button>
                                        <button type="button" onclick="del(<?php echo $service['plug_service_id']; ?>)"
                                                class="btn btn-danger btn-sm m-l-5">删除
                                        </button>
                                    </td>
                                </tr>
                                <?php
                            }
                            ?>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="col-lg-3">
        <?php
        if(isset($update_service)){
            ?>
            <div class="card">
                <div class="card-title">
                    编辑首页服务
                </div>
                <div class="card-body">
                    <form method="post" id="form-edit" action="index.php?r=plugins/service">
                        <input type="hidden" name="action_type" value="updatedo">
                        <input type="hidden" name="plug_service_id" value="<?php echo $update_service['plug_service_id']; ?>"/>
                        <div class="form-group">
                            <label>图标</label>
                            <input class="form-control" type="text" value="<?php echo $update_service['icon_cls']; ?>" name="icon_cls">
                        </div>
                        <div class="form-group">
                            <label>标题</label>
                            <input class="form-control" type="text" value="<?php echo $update_service['title']; ?>" name="title">
                        </div>
                        <div class="form-group">
                            <label>描述</label>
                            <textarea name="description" rows="3" class="form-control" style="height: 100px;"><?php echo $update_service['description']; ?></textarea>
                        </div>
                        <div class="form-group">
                            <label>排序</label>
                            <input class="form-control" type="text" value="<?php echo $update_service['seq']; ?>" name="seq">
                        </div>
                        <button type="submit" class="btn btn-primary">保存</button>
                    </form>
                </div>
            </div>
            <?php
        }else{
            ?>
            <div class="card">
                <div class="card-title">
                    新增首页服务
                </div>
                <div class="card-body">
                    <form method="post" id="form-edit" action="index.php?r=plugins/service">
                        <input type="hidden" name="action_type" value="insert">
                        <input type="hidden" name="plug_service_id" value="0"/>
                        <div class="form-group">
                            <label>图标</label>
                            <input class="form-control" type="text" value="" name="icon_cls">
                        </div>
                        <div class="form-group">
                            <label>标题</label>
                            <input class="form-control" type="text" value="" name="title">
                        </div>
                        <div class="form-group">
                            <label>描述</label>
                            <textarea name="description" rows="3" class="form-control" style="height: 100px;"></textarea>
                        </div>
                        <div class="form-group">
                            <label>排序</label>
                            <input class="form-control" type="text" value="" name="seq">
                        </div>
                        <button type="submit" class="btn btn-primary">保存</button>
                    </form>
                </div>
            </div>
            <?php
        }
        ?>
    </div>
</div>
<script>
    function del(plug_service_id) {
        $("#form-list").find("input[name=plug_service_id]").val(plug_service_id);
        $("#form-list").find("input[name=action_type]").val("delete");
        $("#form-list").submit();
    }

    function edit(plug_service_id) {
        $("#form-list").find("input[name=plug_service_id]").val(plug_service_id);
        $("#form-list").find("input[name=action_type]").val("update");
        $("#form-list").submit();
    }
</script>